package com.qf.bank.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.qf.bank.dealapi.api.DealApi;
import com.qf.bank.dealapi.po.TransferAccounts;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: bank
 * @description: 交易信息
 * @author: 徐毫杰
 * @create: 2019-12-06 21:23
 **/
@RestController
@RequestMapping("/deals")
public class DealController {
    @Resource
    private DealApi dealApi;

    /**
     * 分页
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public Page<TransferAccounts> page(@RequestParam int current, @RequestParam int size) {
        return dealApi.page(current, size);
    }

    /**
     * 增加转账记录
     */
    @RequestMapping(value = "/", method = RequestMethod.POST)
    public Boolean setInsert(@RequestBody TransferAccounts transferAccounts) {
        return dealApi.setInsert(transferAccounts);
    }

    /**
     * 删除转账记录
     */
    @RequestMapping(value = "/{transferAccountsId}", method = RequestMethod.DELETE)
    public Boolean getDeleteId(@PathVariable(value = "transferAccountsId") int transferAccountsId) {
        return dealApi.getDeleteId(transferAccountsId);
    }

    /**
     * 删除多个转账
     */
    @RequestMapping(value = "/", method = RequestMethod.DELETE)
    public Boolean getDelete(@RequestBody List<Integer> list) {
        return dealApi.getDelete(list);
    }

    /**
     * 修改转账记录
     */
    @RequestMapping(value = "/", method = RequestMethod.PATCH)
    public Boolean getChangeId(@RequestBody TransferAccounts transferAccounts) {
        return dealApi.getChangeId(transferAccounts);
    }

    /**
     * 查询转账记录
     */
    @RequestMapping(value = "/{transferAccountsId}", method = RequestMethod.GET)
    public TransferAccounts getById(@PathVariable(value = "transferAccountsId") int transferAccountsId) {
        return dealApi.getById(transferAccountsId);
    }
}
